import request from "@/utils/request";
import { IQueryParams, IIdParams, ITableListItem } from "./data.d";

// 列表
export async function queryList(data?: IQueryParams): Promise<any> {
	return request({
		url: "/nutrition/admin/role/pageList",
		method: "post",
		data,
	});
}

// 新增
export async function addItem(data: ITableListItem): Promise<any> {
	return request({
		url: "/nutrition/admin/role",
		method: "post",
		data,
	});
}

// 编辑
export async function editItem(data: ITableListItem): Promise<any> {
	return request({
		url: "/nutrition/admin/role",
		method: "put",
		data,
	});
}
// 获取详情
export async function getItem(params: IIdParams): Promise<any> {
	return request({
		url: "/nutrition/admin/role",
		method: "get",
		params,
	});
}

// 删除
export async function deleteItem(params: IIdParams): Promise<any> {
	return request({
		url: "/nutrition/admin/role",
		method: "delete",
		params,
	});
}

// 获取角色所有权限
export async function getMenuAll(params: IIdParams): Promise<any> {
	return request({
		url: "/nutrition/admin/role/permissions",
		method: "get",
		params,
	});
}
// 修改角色权限
export async function assignMenu(data: any): Promise<any> {
	return request({
		url: "/nutrition/admin/role/permissions",
		method: "post",
		data,
	});
}
